﻿@model Himall.Web.Areas.SellerAdmin.Models.ProductCreateModel

@{
    var isEdit = ViewBag.IsEdit == true;
    var curft = Model.FreightTemplates.FirstOrDefault(d => d.Id == Model.FreightTemplateId);
    if (!Model.Volume.HasValue)
    {
        Model.Volume = 0;
    }
    if (!Model.Weight.HasValue)
    {
        Model.Weight = 0;
    }
}

<div class="container Sclear-B">
    <ul class="choose-step">
        <li class="step step1 @(isEdit ? "" : "active")">
            step.1 &nbsp;&nbsp;&nbsp;选择商品分类
            <span class="border"></span>
            <span class="border-n Sclear-P32"></span>
        </li>
        <li class="step step2 @(isEdit ? "active" : "")">
            step.2 &nbsp;&nbsp;&nbsp;编辑基本信息
            <span class="border"></span>
            <span class="border-n Sclear-P32"></span>
        </li>       
        <li class="step step4">step.3 &nbsp;&nbsp;&nbsp;编辑商品详情</li>

    </ul>

    <div class="form-horizontal step step1 publish-step1 @(isEdit?"hidden":"")" tep>
        <div id="categoryDiv">
            @{var categoryHtml = new List<string>();

                Action<List<Himall.Web.Areas.SellerAdmin.Models.CategoryGroup>, int, long?> fun = null;

                fun = (list, depth, pid) =>
                {
                    if (categoryHtml.Count == depth)
                    {
                        categoryHtml.Add("");
                    }

                    var lis = "";
                    foreach (var item in list)
                    {
                        lis += string.Format("<li{0} id=\"{1}\"{2} path=\"{3}\" typeId=\"{4}\" r=\"{6}\" rone=\"{7}\" rtwo=\"{8}\" rthree=\"{9}\">{5}</li>", depth > 0 ? " class=\"hidden\"" : "", item.Id, pid.HasValue ? " pid=\"" + pid.Value + "\"" : "", item.Path, item.TypeId, item.Name,item.CommisRate,item.CommisRateOne,item.CommisRateTwo,item.CommisRateThree);
                        if (item.SubCategorys != null && item.SubCategorys.Count > 0)
                        {
                            fun(item.SubCategorys, depth + 1, item.Id);
                        }
                    }

                    categoryHtml[depth] += lis;
                };

                if (Model.CategoryGroups != null && Model.CategoryGroups.Count > 0)
                {
                    fun(Model.CategoryGroups, 0, null);
                }

                foreach (var item in categoryHtml)
                {
                    <div class="pub-inline">
                        <ul>
                            @Html.Raw(item)
                        </ul>
                    </div>
                }
            }
        </div>

        <span class="btn btn-default step Sclear-P71" step="step2">下一步</span>
    </div>

    <div class="form-horizontal step step2 @(isEdit ? "" : "hidden")" id="release-pro">
        <div class="pro-info clearfix">
            <div class="pro-info-left col-sm-2">商品信息</div>
            <div class="pro-info-right col-sm-10">
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>平台分类：</label>
                    <div class="col-sm-10">
                        @Html.HiddenFor(p => p.CategoryId, new
                   {
                       id = "categoryId"
                   })
                        <span id="selectCategoryPath"></span>
                        <a style="margin-left:15px;cursor:pointer" class="btn step" step="step1">编辑</a>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">品牌：</label>
                    <div class="col-sm-10">
                        <select class="form-control input-sm w250" id="brand" name="BrandId">
                            <option value="0">请选择品牌</option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>商品名称：</label>
                    <div class="col-sm-4">
                        @Html.TextBoxFor(p => p.ProductName, new
                   {
                       @class = "form-control input-sm w350"
                   })
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">广告词：</label>
                    <div class="col-sm-4">
                        <textarea class="form-control input-sm w350" name="ShortDescription" rows="5" cols="20">@(Model.ShortDescription)</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>商城价：</label>
                    <div class="col-sm-2">
                        @{
                            var htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("id", "txtMallPrice");
                            htmlAttributes.Add("class", "form-control input-sm w120 inline price");
                            htmlAttributes.Add("onchange", "$('#skuExs_salePrice').val(this.value)");
                            htmlAttributes.Add("min", "0.01");
                            if (Model.HasSKU)
                            {
                                htmlAttributes.Add("readonly", "readonly");
                            }
                        }
                        @Html.TextBoxFor(p => p.MinSalePrice, htmlAttributes)
                    </div>
                    <div class="col-sm-2"><span class="Sclear-P40">元 (精确到0.01)</span></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>市场价：</label>
                    <div class="col-sm-2">
                        @Html.TextBoxFor(p => p.MarketPrice, new
                   {
                       @class = "form-control input-sm w120 price"
                   })
                    </div>
                    <div class="col-sm-2"><span class="Sclear-P40">元 (精确到0.01)</span></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>库存：</label>
                    <div class="col-sm-10">
                        @Html.TextBoxFor(p => p.Stock, new
                   {
                       id = "txtStock",
                       @class = "form-control input-sm w120",
                       onchange = "$('#skuExs_stock').val(this.value);"
                   })
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label"><span class="red">*</span>商品货号：</label>
                    <div class="col-sm-10">
                        @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120");
                        }
                        @Html.TextBoxFor(p => p.ProductCode, htmlAttributes)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>计量单位：</label>
                    <div class="col-sm-10">
                        @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120");
                            htmlAttributes.Add("id", "txtMeasureUnit");
                        }
                        @Html.TextBoxFor(p => p.MeasureUnit, htmlAttributes)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>限购数：</label>
                    <div class="col-sm-2">
                        @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120 inline");
                            htmlAttributes.Add("id", "txtMaxBuyCount");
                        }
                        @Html.TextBoxFor(p => p.MaxBuyCount, htmlAttributes)
                    </div>
                    <div class="col-sm-6"><span class="Sclear-P40">单个ID最多购买数量，0表示不限制</span></div>
                </div>

                <div class="form-group safestock @(Model.HasSKU?"hidden":"")">
                    <label class="col-sm-2 control-label" for="">警戒库存：</label>
                    <div class="col-sm-10">
                        @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120");
                            htmlAttributes.Add("id", "txtSafeStock");
                            htmlAttributes.Add("onchange", "$('#skuExs_safeStock').val(this.value)");
                        }
                        @Html.TextBoxFor(p => p.SafeStock, htmlAttributes)
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">商家分类：</label>
                    <div class="col-sm-8">
                        <table class="table table-bordered" id="tableCategory">
                            <thead>
                                <tr><th>需要关联的分类</th><th class="td-operate">操作</th></tr>
                            </thead>
                            <tbody id="cateBody">
                                @helper categorySelect(long? defaultId)
                                {
                                <tr>
                                    <td>
                                        <select name="GoodsCategory">
                                            <option value="0">请选择</option>
                                            @{
                                                var dic = new Dictionary<long, string>();
                                                for (int i = 0; i < Model.ShopCategorys.Count; i++)
                                                {
                                                    var item = Model.ShopCategorys[i];
                                                    var isParent = item.ParentCategoryId == 0;
                                                    var key = isParent ? item.Id : item.ParentCategoryId;
                                                    var html = string.Format("<option value='{0}'{1}>{2}{3}</option>", item.Id, defaultId.HasValue && item.Id == defaultId.Value ? " selected" : "", isParent ? "" : "&nbsp;&nbsp;&nbsp;&nbsp;", item.Name);

                                                    if (dic.ContainsKey(key))
                                                    {
                                                        html = isParent ? html + dic[key] : (dic[key] + html);
                                                    }
                                                    dic[key] = html;
                                                }
                                            }
                                            @Html.Raw(string.Join("", dic.Values.ToArray()))
                                        </select>
                                    </td>
                                    <td><span class="del" style="cursor:pointer; ">删除</span></td>
                                </tr>
}
                                @if (Model.GoodsCategory != null && Model.GoodsCategory.Length > 0)
                                {
                                    foreach (var item in Model.GoodsCategory)
                                    {
                                        @categorySelect(item)
                                    }
                                }
                                else
                                {
                                    @categorySelect(null)
                                }
                            </tbody>
                        </table>
                        <a style="cursor: pointer; display: inline-block; margin: 8px 0 20px 0px; text-decoration: none;" id="createCategory">
                            <span class="glyphicon glyphicon-plus-sign" style="margin-right: 10px;"></span>增加关联分类
                        </a>
                        <span class="red">(未关联分类，商家和门店分类下将不会展示商品，建议做关联)</span>
                    </div>
                </div>
            </div>
        </div>

        <div class="pro-info clearfix">
            <div class="pro-info-left col-sm-2">商品属性</div>
            <div class="pro-info-right col-sm-10 pro-attr-right">
                <div class="form-group spec hidden">
                    <label class="col-sm-2 control-label" for="">开启规格：</label>
                    <div class="col-sm-10">
                        <div class="onoffswitch">
                            @if (Model.HasSKU)
                            {
                                <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="ckbSpecifications" checked>
                            }
                            else
                            {
                                <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="ckbSpecifications">
                            }
                            <label class="onoffswitch-label" for="ckbSpecifications">
                                <span class="onoffswitch-inner"></span>
                                <span class="onoffswitch-switch"></span>
                            </label>
                        </div>
                        @if (Model.HasSKU)
                        {
                            <a id="changeSpecification" style="display:inline;cursor:pointer;">修改规格</a>
                        }
                        else
                        {
                            <a class="hidden" id="changeSpecification" style="display:inline;cursor:pointer;">修改规格</a>
                        }

                        <span class="open-tips Sclear-P46" style="display:inline"><i></i>开启规格后可根据规格设置不同的价格、库存及主图</span>
                    </div>
                </div>
                <div class="form-group spec hidden j_spec">
                    <label class="col-sm-2 control-label" for="">商品规格：</label>
                    <div class="col-sm-10" id="skusDiv">
                        @if (Model.HasSKU)
                        {
                            var hasVersion = Model.SKUExs.Any(p => !string.IsNullOrWhiteSpace(p.Version));
                            var hasColor = Model.SKUExs.Any(p => !string.IsNullOrWhiteSpace(p.Color));
                            var hasSize = Model.SKUExs.Any(p => !string.IsNullOrWhiteSpace(p.Size));
                            var colspan = 0;
                            colspan += (hasVersion ? 1 : 0) + (hasColor ? 1 : 0) + (hasSize ? 1 : 0);

                            var imgTableData = Model.SKUExs.Where(p => p.ColorId > 0).GroupBy(p => p.ColorId).Select(p => new
                            {
                                p.Key,
                                Value = p.FirstOrDefault()
                            });
                            if (imgTableData.Any())
                            {
                                <table class="table table-bordered img">
                                    <thead>
                                        <tr>
                                            <th><label name="Color_Alias_Img"></label></th>
                                            <th>
                                                图片（可不上传，建议尺寸700*700）
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var item in imgTableData)
                                        {
                                            <tr id="1_@item.Key" data-name="Color" data-value="@item.Value.Color">
                                                <td>@item.Value.Color</td>
                                                <td class="table-img-file">
                                                    <div class="upload_pic" style="background-image:url(@Himall.Core.HimallIO.GetImagePath(item.Value.ShowPic)?r=@(new Random().Next()))">
                                                        <input type="hidden" value="@Himall.Core.HimallIO.GetImagePath(item.Value.ShowPic)" />
                                                    </div>
                                                    @if (string.IsNullOrWhiteSpace(item.Value.ShowPic))
                                                    {
                                                        <a class="hidden reset pic">删除</a>
                                                    }
                                                    else
                                                    {
                                                        <a class="reset pic">删除</a>
                                                    }
                                                    <input class="upload pic" type="button" value="选择文件" />
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            }

                            <div class="form-inline batch-attr-setting text-right">
                                <div class="form-group">
                                    <label class="label-inline w75">批量设置:</label>
                                    <input class="form-control input-sm w95" placeholder="商城价" for="SalePrice" />
                                </div>
                                <div class="form-group">
                                    <input class="form-control input-sm w95" placeholder="库存" for="Stock" />
                                </div>
                                <div class="form-group">
                                    <input class="form-control input-sm w95" placeholder="警戒库存" for="SafeStock" />
                                </div>
                                <div class="form-group">
                                    <span class="btn btn-default">确定</span>
                                </div>
                            </div>

                            <table class="table table-bordered sku mt20">
                                <thead>
                                    <tr>
                                        @if (hasVersion)
                                        {
                                            <th><label name="Version_Alias"></label></th>
                                        }
                                        @if (hasColor)
                                        {
                                            <th><label name="Color_Alias"></label></th>
                                        }
                                        @if (hasSize)
                                        {
                                            <th><label name="Size_Alias"></label></th>
                                        }
                                        <th><span class="red">*</span>商城价</th>
                                        <th><span class="red">*</span>库存</th>
                                        <th>警戒库存</th>
                                        <th>货号</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @for (var i = 0; i < Model.SKUExs.Length; i++)
                                    {
                                        var sku = Model.SKUExs[i];
                                        <tr version="@sku.Version" color="@sku.Color" size="@sku.Size">
                                            @if (!string.IsNullOrWhiteSpace(sku.Version))
                                            {
                                                <td>
                                                    <label>@sku.Version</label>
                                                    <input name="SKUExs[@i].Version" type="hidden" value="@sku.Version">
                                                    <input name="SKUExs[@i].VersionId" type="hidden" value="@sku.VersionId">
                                                </td>
                                            }
                                            @if (!string.IsNullOrWhiteSpace(sku.Color))
                                            {
                                                <td>
                                                    <label>@sku.Color</label>
                                                    <input name="SKUExs[@i].Color" type="hidden" value="@sku.Color">
                                                    <input name="SKUExs[@i].ColorId" type="hidden" value="@sku.ColorId">
                                                </td>
                                            }
                                            @if (!string.IsNullOrWhiteSpace(sku.Size))
                                            {
                                                <td>
                                                    <label>@sku.Size</label>
                                                    <input name="SKUExs[@i].Size" type="hidden" value="@sku.Size">
                                                    <input name="SKUExs[@i].SizeId" type="hidden" value="@sku.SizeId">
                                                </td>
                                            }
                                            <td>
                                                @Html.TextBoxFor(p => p.SKUExs[i].SalePrice, new { @class = "form-control", onchange = "SKUSalePriceChange(this)" })
                                            </td>
                                            <td>
                                                @Html.TextBoxFor(p => p.SKUExs[i].Stock, new { @class = "form-control", onchange = "SKUStockChange(this)" })
                                            </td>
                                            <td>
                                                @Html.TextBoxFor(p => p.SKUExs[i].SafeStock, new { @class = "form-control" })
                                            </td>
                                            <td>
                                                @Html.TextBoxFor(p => p.SKUExs[i].Sku, new { @class = "form-control,pro-num" })
                                                <input name="SKUExs[@i].ShowPic" type="hidden" value="@sku.ShowPic">
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        }
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">商品属性：</label>
                    <div class="col-sm-10" id="attrDiv">
                    </div>
                </div>
            </div>
        </div>
        <div class="pro-info clearfix">
            <label class="pro-info-left col-sm-2" for="">分佣信息：</label>
            <div class="pro-info-right col-sm-10 pro-attr-right">
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">开启规格：</label>
                    <div class="col-sm-10">
                        <div class="onoffswitch">
                            @if (Model.IsUseCategoryCommis)
                            {
                                <input type="checkbox" name="UseCategoryCommis" class="onoffswitch-checkbox" id="ckbUseCategoryCommis" checked>
                            }
                            else
                            {
                                <input type="checkbox" name="UseCategoryCommis" class="onoffswitch-checkbox" id="ckbUseCategoryCommis">
                            }
                            <label class="onoffswitch-label" for="ckbUseCategoryCommis">
                                <span class="onoffswitch-inner"></span>
                                <span class="onoffswitch-switch"></span>
                            </label>
                        </div>
                        <span class="open-tips Sclear-P46" style="display:inline"><i></i>开启后可设置不同的分佣比例</span>
                        @Html.HiddenFor(x=>x.IsUseCategoryCommis)
                      </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">一级分佣比例：</label>

                    <div class="col-sm-3">
                        @{
                                htmlAttributes = new Dictionary<string, object>();
                                if (Model.IsUseCategoryCommis)
                                {
                                    htmlAttributes.Add("readonly", "readonly");
                                }
                                htmlAttributes.Add("class", "form-control input-sm");
                                htmlAttributes.Add("id", "txtCommisRateOne");
                        }
                        @Html.TextBoxFor(p => p.CommisRateOne, htmlAttributes)
                    </div>
                    <div class="col-sm-6"><span class="help-default">%</span></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">二级分佣比例：</label>
                    <div class="col-sm-3">
                        @{
                                htmlAttributes = new Dictionary<string, object>();
                                if (Model.IsUseCategoryCommis)
                                {
                                    htmlAttributes.Add("readonly", "readonly");
                                }
                                htmlAttributes.Add("class", "form-control input-sm");
                                htmlAttributes.Add("id", "txtCommisRateTwo");
                        }
                        @Html.TextBoxFor(p => p.CommisRateTwo, htmlAttributes)
                    </div>
                    <div class="col-sm-6"><span class="help-default">%</span></div>

                </div>
                @*<div class="form-group">
                    <label class="col-sm-2 control-label" for="">三级分佣比例：</label>
                    <div class="col-sm-3">
                        @{
                                htmlAttributes = new Dictionary<string, object>();
                                if (Model.IsUseCategoryCommis)
                                {
                                    htmlAttributes.Add("readonly", "readonly");
                                }
                                htmlAttributes.Add("class", "form-control input-sm");
                                htmlAttributes.Add("id", "txtCommisRateThree");
                        }
                        @Html.TextBoxFor(p => p.CommisRateThree, htmlAttributes)
                    </div>
                    <div class="col-sm-6"><span class="help-default">%</span></div>

                </div>*@
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">分享分佣比例：</label>
                    <div class="col-sm-3">
                        @{
                                htmlAttributes = new Dictionary<string, object>();
                                if (Model.IsUseCategoryCommis)
                                {
                                    htmlAttributes.Add("readonly", "readonly");
                                }
                                htmlAttributes.Add("class", "form-control input-sm");
                                htmlAttributes.Add("id", "txtCommisRate");
                        }
                        @Html.TextBoxFor(p => p.CommisRate, htmlAttributes)
                    </div>
                    <div class="col-sm-6"><span class="help-default">%</span></div>

                </div>
            </div>
        </div>
            <div class="pro-info clearfix">
                <div class="pro-info-left col-sm-2">物流信息</div>
                <div class="pro-info-right col-sm-10">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for=""><span class="red">*</span>运费模板：</label>
                        <div class="col-sm-8">
                            @Html.DropDownListFor(p => p.FreightTemplateId, Model.FreightTemplates.Select(ft => new SelectListItem()
                   {
                       Selected = Model.FreightTemplateId == ft.Id,
                       Value = ft.Id.ToString(),
                       Text = ft.Name + (ft.ValuationMethod == Himall.CommonModel.ValuationMethodType.Weight ? "【按重量】" : (ft.ValuationMethod == Himall.CommonModel.ValuationMethodType.Bulk ? "【按体积】" : ""))
                   }), "请选择运费模板", new
                   {
                       @class = "input-sm w260"
                   })
                            <a style="cursor: pointer;display: inline-block;margin:8px 0 20px 0px;text-decoration:none;" id="addFreightTemplate">
                                <span class="glyphicon glyphicon-plus-sign" style="margin-right:10px;"></span>新增运费模版
                            </a>
                        </div>
                    </div>

                    <div class="form-group" id="divVolume">
                        <label for="" class="col-sm-2 control-label"><span class="red">*</span>体积(M<sup>3</sup>)：</label>
                        <div class="col-sm-4">
                            @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120");
                            htmlAttributes.Add("id", "txtMeasureUnit");
                            }
                            @Html.TextBoxFor(p => p.Volume, htmlAttributes)
                        </div>
                    </div>
                    <div class="form-group" id="divWeight">
                        <label for="" class="col-sm-2 control-label"><span class="red">*</span>重量(kg)：</label>
                        <div class="col-sm-4">
                            @{
                            htmlAttributes = new Dictionary<string, object>();
                            htmlAttributes.Add("class", "form-control input-sm w120");
                            htmlAttributes.Add("id", "txtMeasureUnit");
                            }
                            @Html.TextBoxFor(p => p.Weight, htmlAttributes)
                        </div>
                    </div>
                </div>
            </div>
            <input id="txtCategoryPath" name="CategoryPath" type="hidden" value="@(Model.CategoryPath)" />
            <input id="txtTypeId" name="TypeId" type="hidden" value="@(Model.TypeId)" />
            @{var hasSKU = Model.SKUExs != null && Model.SKUExs.Length > 0;}
            <input id="skuExs_salePrice" name="SKUExs[0].SalePrice" type="hidden" value="@(hasSKU ? Model.SKUExs[0].SalePrice : 0)" />
            <input id="skuExs_costPrice" name="SKUExs[0].CostPrice" type="hidden" value="@(hasSKU ? Model.SKUExs[0].CostPrice : 0)" />
            <input id="skuExs_stock" name="SKUExs[0].Stock" type="hidden" value="@(hasSKU ? Model.SKUExs[0].Stock : 0)" />
            <input id="skuExs_safeStock" name="SKUExs[0].SafeStock" type="hidden" value="@(hasSKU ? Model.SKUExs[0].SafeStock : 0)" />
            <input name="SKUExs[0].Id" type="hidden" value="@(hasSKU ? Model.SKUExs[0].Id : "")" />
            <input type="hidden" id="HasSKU" value="@(Model.HasSKU ? 1 : 0)" />
            <div class="pro-detail-btn clearfix">
                <span class="btn btn-default step" step="step1">上一步</span>
                <span class="btn btn-default step needValid fr Sclear-P71" step="step3">下一步</span>
            </div>
        </div>

    <div class="form-horizontal step step3 hidden" id="release-detail">
        <div class="pro-info clearfix">
            <div class="pro-info-left col-sm-2">详情描述</div>
            <div class="pro-info-right col-sm-10 pro-attr-right">
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>主图：</label>
                    <div class="col-sm-10 pics">
                        @{
                            Func<int, string> getImagePath = i =>
                            {
                                if (Model.Pics != null && Model.Pics.Length > i)
                                    return Model.Pics[i];

                                if (string.IsNullOrEmpty(Model.ImagePath))
                                    return null;

                                if (Himall.Core.HimallIO.ExistFile(Model.RelativePath + string.Format("/{0}.png", i + 1)))
                                    return string.Format("{0}/{1}.png?r={2}", Model.ImagePath, i + 1, new Random().Next());
                                else
                                    return null;
                            };
                        }
                        <div class="product pic"><div class="upload_pic" style="background-image:url('@getImagePath(0)')"><input type="hidden" name="Pics[0]" value="@getImagePath(0)" /></div><span class="upload pic btn">上传图片</span><i class="del hide">x</i></div>
                        <div class="product pic"><div class="upload_pic" style="background-image:url('@getImagePath(1)')"><input type="hidden" name="Pics[1]" value="@getImagePath(1)" /></div><span class="upload pic btn">上传图片</span><i class="del hide">x</i></div>
                        <div class="product pic"><div class="upload_pic" style="background-image:url('@getImagePath(2)')"><input type="hidden" name="Pics[2]" value="@getImagePath(2)" /></div><span class="upload pic btn">上传图片</span><i class="del hide">x</i></div>
                        <div class="product pic"><div class="upload_pic" style="background-image:url('@getImagePath(3)')"><input type="hidden" name="Pics[3]" value="@getImagePath(3)" /></div><span class="upload pic btn">上传图片</span><i class="del hide">x</i></div>
                        <div class="product pic"><div class="upload_pic" style="background-image:url('@getImagePath(4)')"><input type="hidden" name="Pics[4]" value="@getImagePath(4)" /></div><span class="upload pic btn">上传图片</span><i class="del hide">x</i></div>

                        <input name="picsValid" picrequired="true" style="width:0;border:0;padding:0" @* 用于验证 *@ />
                        <div class="Sclear-P66"><i class="light-0"></i>主图至少上传一张，建议尺寸：700*700，支持gif、png、jpg、jpeg格式，大小不超过1M</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for=""><span class="red">*</span>商品描述：</label>

                    <div class="col-sm-10 des">
                        <!-- Nav tabs -->
                        <ul class="nav nav-tabs">
                            @*<li class="mdes"><a style="padding:8px 20px; cursor: pointer;">PC端</a></li>*@
                            <li class="active"><a style="padding:8px 20px; cursor: pointer;">移动端</a></li>
                        </ul>

                        <!-- Tab panes -->
                        <div class="tab-content">
                            @*<div class="tab-pane active">
                                <script id="desContainer" name="Description.Description" type="text/plain" style="width:100%; height:250px;">
                                    @if (Model.Description != null && !string.IsNullOrEmpty(Model.Description.Description))
                                    {
                                        @Html.Raw(Model.Description.Description)
                                    }
                                </script>
                            </div>*@
                            <div class="tab-pane active">
                                <script id="mdesContainer" name="Description.MobileDescription" type="text/plain" style="width:100%; height:250px;">
                                    @if (Model.Description != null && !string.IsNullOrEmpty(Model.Description.MobileDescription))
                                    {
                                        @Html.Raw(Model.Description.MobileDescription)
                                    }
                                </script>
                            </div>
                            <div style="display:none">
                                @*<textarea id="oldDes" disabled>@(Model.Description != null ? Model.Description.Description : "")</textarea>*@
                                <textarea id="oldMobileDes" disabled>@(Model.Description != null ? Model.Description.MobileDescription : "")</textarea>
                            </div>
                        </div>
                        <input name="des" desrequired="true" style="width:0;border:0;padding:0" @* 用于验证 *@ />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="">版式：</label>
                    <div class="col-sm-5">
                        <select class="form-control input-sm" name="Description.DescriptionPrefixId">
                            <option value="0">请选择顶部版式</option>
                            @foreach (var item in Model.DescriptionTemplates)
                            {
                                if (item.Position == Himall.Entity.TemplatePosition.Top)
                                {
                                    if (Model.Description != null && item.Id == Model.Description.DescriptionPrefixId)
                                    {
                                        <option value="@item.Id" selected>@item.Name</option>
                                    }
                                    else
                                    {
                                        <option value="@item.Id">@item.Name</option>
                                    }
                                }
                            }
                        </select>
                    </div>
                    <div class="col-sm-5">
                        <select class="form-control input-sm" name="Description.DescriptiondSuffixId">
                            <option value="0">请选择底部版式</option>
                            @foreach (var item in Model.DescriptionTemplates)
                            {
                                if (item.Position == Himall.Entity.TemplatePosition.Bottom)
                                {
                                    if (Model.Description != null && item.Id == Model.Description.DescriptiondSuffixId)
                                    {
                                        <option value="@item.Id" selected>@item.Name</option>
                                    }
                                    else
                                    {
                                        <option value="@item.Id">@item.Name</option>
                                    }
                                }
                            }
                        </select>
                    </div>
                </div>
            </div>
        </div>

        <div class="pro-detail-btn clearfix">
            <span class="btn btn-default step" step="step2">上一步</span>
            <input id="submit" class="btn btn-default Sclear-P71 fr" type="submit" value="发布商品" />
            @if (!isEdit || Model.SaleStatus == Himall.Entity.ProductSaleStatus.InDraft)
            {
                <input id="inDraft" class="btn btn-default  fr" type="submit" value="存入草稿箱" />}
        </div>
    </div>
</div>

<div class="hidden">
    <div id="specificationsDiv"></div>
    <input type="hidden" id="CurFTVM" name="CurFTVM" value="@(curft!=null?curft.ValuationMethod.GetHashCode():0)" />"
</div>
